<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="https://cdn.bootcss.com/normalize/7.0.0/normalize.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <script src="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/js/bootstrap.js"></script>

    <style>
        #add {
            color: black;
            font-size: 16px;
        }

        #add:hover {
            color: black;
            background-color: #9d9d9d;
        }
    </style>
    <script>
        //获取页面数据，并封装成json格式数据
        $(function () {
            $("#add").click(function () {
                //获取用户输入数据
                let wareshouse_data = {
                    "goods_name_id": $("#goods_name").val(),
                    "norms": $("#norms").val(),
                    "type": $("#type").val(),
                    "price": $("#price").val(),
                    "number": $("#number").val(),
                    "total_price": $("#total_price").val(),
                    "Agent_name": $("#Agent_name").val(),
                    "comment": $("#comment").val(),
                    "supplier_id": $("#supplier").val(),
                    "in_Warehouse_time": $("#in_Warehouse_time").val(),
                    "keep_Warehouse_id": $("#keep_Warehouse").val()
                }

                //将获取的额数据封装成json格式
                let warehouseJson = {
                    warehouse: JSON.stringify(wareshouse_data)
                }

                /*$.get("http://localhost:8080/warehouse/insertwarehousemangagment?warehouseJson", function (result) {
                    if (result.status === 200) {
                        alert("数据添加成功")
                    } else {
                        alert("数据添加失败")
                    }
                })*/


                $.ajax({
                    type: "GET",
                    url: "http://localhost:8080/warehouse/insertwarehousemangagment",
                    data: warehouseJson,
                    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                    dataType: "Json",  //dataType:服务器返回的数据类型 text/xml/script/html/json/jsonp
                    success: function (result) {
                        if (result.status === 200) {
                            alert(warehouseJson)
                        }if (result.status===405){
                            console.log("405添加失败")
                        }
                        else {
                            console.log("status!=200添加失败")
                        }
                    }
                })
            })
        });
    </script>

</head>
<body>
<div class="container-fluid">
    <div class="row clearfix" style="width: 1500px; margin: 0 auto">
        <div class="container-fluid row"
             style="border-bottom: solid 1px #C0C0C0; height: 60px; width: 100%; margin: 0 auto">
            <span type="text" class="" style="font-size: 25px;line-height: 60px ">新增入库单</span>
        </div>
        <div style="width: 100%; margin: 0 auto; height: 20px"></div>

        <div class="container-fluid row" style="background-color: #f5f5f5;height: 40px; width: 1000px; margin: 0 auto">
            <span type="text" class="" style="font-size: 20px;line-height: 40px ">入库信息</span>
        </div>
        <div class="clearfix row " style="padding: 10px 0 10px 0">
            <div class="pull-left col-lg-offset-2 col-lg-3">
                供应商名称<input type="text" class="form-control" placeholder="供应商名称" id="supplier" name="supplier">
            </div>
            <div class="pull-left col-lg-offset-2 col-lg-3">
                入库时间<input type="datetime-local" class="date-picker form-control" style="" placeholder="入库时间"
                           id="in_Warehouse_time"
                           name="in_Warehouse_time">
            </div>
        </div>
        <div class="clearfix row " style="padding: 10px 0 20px 0">
            <div class="pull-left col-lg-offset-2 col-lg-3">
                入库仓库<input type="text" class="form-control" placeholder="入库仓库" id="keep_warehouse"
                           name="keep_warehouse">
            </div>
            <div class="pull-left col-lg-offset-2 col-lg-3">
                经手人<input type="text" class="form-control" style="" placeholder="经手人" id="Agent_name" name="Agent_name">
            </div>
        </div>

        <div class="container-fluid row" style="background-color: #f5f5f5;height: 40px; width: 1000px; margin: 0 auto">
            <span type="text" class="" style="font-size: 20px;line-height: 40px ">货物信息</span>
        </div>
        <div class="clearfix row " style="padding: 10px 0 10px 0">
            <div class="pull-left col-lg-offset-2 col-lg-3">
                名称<input type="text" class="form-control" placeholder="名称" id="goods_name" name="goods_name">
            </div>
            <div class="pull-left col-lg-offset-2 col-lg-3">
                库存<input type="text" class="form-control" style="" placeholder="库存" id="stock" name="stock">
            </div>

        </div>
        <div class="clearfix row " style="padding: 10px 0 10px 0">
            <div class="pull-left col-lg-offset-2 col-lg-3">
                规格<input type="text" class="form-control" placeholder="规格" id="norms" name="norms">
            </div>
            <div class="pull-left col-lg-offset-2 col-lg-3">
                型号<input type="text" class="form-control" style="" placeholder="型号" id="type" name="type">
            </div>
        </div>


        <div class="clearfix row " style="padding: 10px 0 10px 0">
            <div class="pull-left col-lg-offset-2 col-lg-3">
                单价<input type="text" class="form-control" placeholder="单价" id="price" name="price">
            </div>
            <div class="pull-left col-lg-offset-2 col-lg-3">
                数量<input type="text" class="form-control" style="" placeholder="当前存量" id="number" name="number">
            </div>
        </div>


        <div class="clearfix row " style="padding: 10px 0 10px 0">
            <div class="pull-left col-lg-offset-2 col-lg-3">
                总价<input type="text" class="form-control" placeholder="总价" id="total_price" name="total_price">
            </div>
            <div class="pull-left col-lg-offset-2 col-lg-3">
                备注<input type="text" class="form-control" style="" placeholder="备注" id="comment" name="comment">
            </div>
        </div>
    </div>
    <div class="container" style="padding-top: 30px; width: 200px; margin: 0 auto">
        <button id="add" class="btn btn-info" style="height: 40px; width: 100px" type="submit">新增
        </button>
    </div>
</div>
</body>
</html>